package com.studyhub.user;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.beans.factory.annotation.Value;
import lombok.extern.slf4j.Slf4j;

/**
 * 用户服务应用主类
 * StudyHub系统的用户管理微服务启动类
 * 负责用户注册、登录、认证、课程管理等功能
 * 集成OpenFeign进行服务间调用，配置MyBatis-Plus进行数据持久化
 * 
 * @author yangwf
 */
@Slf4j
@SpringBootApplication(scanBasePackages = "com.studyhub")
@EnableFeignClients(basePackages="com.studyhub.*")
//扫描mapper
@MapperScan(basePackages = "com.studyhub.user.mapper")
public class UserServiceApplication {
    
    @Value("${server.port:8081}")
    private String serverPort;
    
    public static void main(String[] args) {
        SpringApplication.run(UserServiceApplication.class, args);
    }
    
    @EventListener(ApplicationReadyEvent.class)
    public void printAdminLoginUrl() {
        log.info("=".repeat(80));
        log.info("💻 管理员功能已启用：");
        log.info("🔗 管理员登录: http://localhost:3032/admin/login");
        log.info("🔗 管理员控制台: http://localhost:3032/admin/dashboard");
        log.info("⚡️ 用户服务端口: {}", serverPort);
        log.info("🔐 使用管理员账号登录后可管理系统");
        log.info("📧 支持功能: 消息发送、用户管理、系统设置");
        log.info("=".repeat(80));
    }
}
